function zipImages(){
    var imgs = document.images;
    var zip = new Zip();
    var count = imgs.length;
    var i = count;
    function complete(){
        count--;
        if(count<=0){
            window.location = zip.toDataURL();
        }
    }
    var prefix = location.href;
    var info = document.createElement("pre");
    document.body.insertBefore(info,document.body.firstChild);
    info.innerHTML = "loading...\n"
    prefix = prefix.replace(/^(\w+\:\/\/[^/]*).*/,'$1')
    while(i--){
        var url = imgs[i].src;
        info.innerHTML += url+'\n';
        if(url.indexOf(prefix)==0){
            url = url.substring(prefix.length)
        }
        if(url.charAt() == '/'){
            var path = url.replace(/^\/([^#\?]+).*$/,'$1')
        	zip.addFileAsync(path,url,complete);
        }else{
        	count--;
        }
    }
}
var script = document.createElement("script");
script.src = "http://jsicdn.appspot.com/cdn/=org.jside.sandbox.stream:Zip";
document.body.appendChild(script)
setTimeout(function(){
	script = document.createElement("script");
	script.src = "data:text/javascript,zipImages()"
	document.body.appendChild(script)
},1000);
/*
javascript:var app='http://jsicdn.appspot.com/example/pack.js';var s = document.createElement("script");s.src=app;void(document.body.appendChild(s))
*/


